<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
    String realPath = request.getSession().getServletContext().getRealPath("/");
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <base href="<%=basePath%>">

    <title>上传文件</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <link type="text/css" href="css/base.css" rel="stylesheet"/>
    <script type="text/javascript" src="js/jquery.min.js"></script>
    <script type="text/javascript" src="../js/menu.js"></script>
    <script type="text/javascript" src="<%=basePath%>js/jquery.js"></script>
    <script src='<%=basePath%>dwr/util.js' type= "text/javascript" ></script>
    <script src='<%=basePath%>dwr/engine.js' type= "text/javascript" ></script>
    <script src='<%=basePath%>dwr/interface/resourceCategoryService.js' type= "text/javascript" ></script>
    <script type="text/javascript" src="<%=basePath%>js/sufix.js"></script>

    <script type="text/javascript">
        function checkFile(objForm) {
            var form = objForm;
            var category = form.resourceCategory.value;
            var uploadFile = form.upload.value;
            if(category == "" || category == null){
                $("#sufix_result").html("请选择上传类别");
                return false;
            }
            if (uploadFile != "" && uploadFile != null) {
                if (document.getElementById("sufix_result").innerHTML.toString() != "") {
                    return false;
                }
                form.fileName.value = uploadFile.substring(uploadFile.lastIndexOf("\\") + 1).toLowerCase();
            } else {
                $("#sufix_result").html("没有上传文件");
                return false;
            }
            return true;

        }
    </script>
</head>

<body>
<%@ include file="/page/share/menu.jsp" %>
    <div id="content">
        <h2>上传文件</h2>
        <hr>
        <form action="Upload.action" method="post" enctype="multipart/form-data" onsubmit="return checkFile(this)">
            <table style="margin: 0 auto;padding: 20px 0px; ">

                <input type="hidden" name="owner" value="${person.accout}"/>
                <input type="hidden" name="path" value="<%=realPath%>"/>
                <tr>
                    <td style="text-align: right;width: 100px;">
                        文件:&nbsp
                    </td>
                    <td>
                        <input type="file" name="upload" style="height: 25px;" onchange="verifyFileName()"/>
                        <input type="hidden" name="fileName"/>
                        <div id="sufix_result"></div>
                    </td>
                </tr>
                <tr>
                    <td style="text-align: right;width: 100px;">
                        类别:&nbsp
                    </td>
                    <td>
                        <select name="resourceCategory" style="width: 200px;height: 25px;font-size: 16px;font-family: '微软雅黑';"
                                id="category" onchange="verifyFileName()">
                        </select>
                    </td>
                </tr>
                <tr>
                    <td style="vertical-align: top; padding: 20px 0px;text-align: right;width: 100px;">
                        介绍:&nbsp
                    </td>
                    <td style="padding: 20px 0px 0px 0px;">
                        <textarea name="introduction" style="width: 400px;height: 150px;font-size: 14px;font-family: '微软雅黑'"></textarea>
                    </td>
                </tr>
                <tr>
                    <td style="width: 100px;" ></td>
                    <td>
                        <input type="submit" value="提 交" onMouseOver="this.style.background='#2569c1'" onmouseout="this.style.background='#114a93'" style="cursor:pointer;width:200px;height:30px;font-weight:bold;margin:10px 0px;border: none;background: #2569c1;color: white;font-size: 16px;" />
                    </td>
                </tr>
            </table>
        </form>
    </div>
    <div id="footer">
        <p style="text-align: center;color: #757575;padding: 20px 0 0 0; font:12px;">Copyright © 2010-2013 蓝天白云团队
            版权所有</p>
    </div>

</body>
</html>
